{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6dc1de7-3cf1-48e1-9bf8-49f51f150c90",
   "metadata": {},
   "outputs": [],
   "source": [
    "set1 = {1,2,3,4,4}\n",
    "set2 = {3,4,5}\n",
    "\n",
    "#差集(减去)\n",
    "print(set1-set2)\n",
    "\n",
    "#合集(合在一起)\n",
    "print(set1|set2)\n",
    "\n",
    "#交集(只要重复的)\n",
    "print(set1&set2)\n",
    "\n",
    "#对称差集(只要不重复)\n",
    "print(set1^set2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5970b5b7-4abb-45ad-9a9a-d55ea217165f",
   "metadata": {},
   "source": [
    "二维数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ebfc88af-b2b4-4d3b-a6e1-41789352316f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "li = [1,2,3,4,5]\n",
    "li\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5ffaec6f-8060-4731-a6d2-f5a42fbdb571",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "#一维数据的基础上嵌套一维数据\n",
    "dli = [\n",
    "    [1,2,3,4],\n",
    "    [5,6,7,8],\n",
    "    [9,10,11,12]\n",
    "]\n",
    "dli"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "6016ab46-6325-4b23-a49b-329e6d380325",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "12\n"
     ]
    }
   ],
   "source": [
    "#去操作二维数据\n",
    "#取值 二维数据--->一维数据---->单个\n",
    "print(dli[1][1])\n",
    "#[行][列]\n",
    "print(dli[2][3])\n",
    "\n",
    "#如何遍历\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "bb9ad2ab-2401-49d9-8e32-2d7638adfc09",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n",
      "11\n",
      "12\n"
     ]
    }
   ],
   "source": [
    "#遍历方式1\n",
    "\n",
    "for i in range(len(dli)):\n",
    "    #下标去数据中找值\n",
    "\n",
    "    #遍历当前循环取出的一维数据下标\n",
    "    for j in range(len(dli[i])):\n",
    "        \n",
    "        print(dli[i][j])\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "d9ddf073-fdca-465c-957b-413eb0c35492",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n",
      "11\n",
      "12\n"
     ]
    }
   ],
   "source": [
    "#遍历方式2\n",
    "\n",
    "# 直接遍历值\n",
    "for i in dli:\n",
    "\n",
    "    #i就是行数据\n",
    "    for item in i:\n",
    "        \n",
    "        print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "daaebf91-ec85-4029-b3a3-4f5877669e7b",
   "metadata": {},
   "outputs": [],
   "source": [
    "gtq = {\"name\":\"光头强\",\n",
    "\"address\":{\"province\":\"黑龙江省\",\n",
    "            \"city\":\"哈尔滨市\",\n",
    "            \"street\":\"团结屯\"},\n",
    "\"occupation\":\"伐木工\"}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "fac095ea-b955-4eb2-8ed4-ab025a10c571",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团结屯'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gtq['address']['city']\n",
    "\n",
    "gtq['address']['street']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
